package com.tiancheng.trade.authserver.controller.admin;

import com.tiancheng.trade.authserver.dto.OrgAddUpdateDTO;
import com.tiancheng.trade.authserver.dto.OrgDetailDTO;
import com.tiancheng.trade.authserver.dto.OrgListDTO;
import com.tiancheng.trade.authserver.dto.OrgOptionDTO;
import com.tiancheng.trade.authserver.model.query.OrgQuery;
import com.tiancheng.trade.authserver.service.impl.IAuthOrgService;
import com.tiancheng.trade.commom.core.data.PageInfo;
import com.tiancheng.trade.commom.core.data.Result;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/org")
public class OrgController {
    @Resource
    private IAuthOrgService service;
    @Resource
    private HttpServletRequest request;

    @GetMapping("getOptions")
    //@RequiresPermissions({"auth:org:query"})
    public Result<List<OrgOptionDTO>> getOptions(OrgQuery param) {
        return Result.success(this.service.getOptions(param));
    }

    @GetMapping("/getPageInfo")
    //@RequiresPermissions({"auth:org:query"})
    public Result<PageInfo<OrgListDTO>> getPageInfo(OrgQuery param) {
        return Result.success(this.service.getTengyunPageInfo(param));
    }

    @GetMapping("/getDetail")
    //@RequiresPermissions({"auth:org:detail"})
    public Result<OrgDetailDTO> getDetail(@RequestParam String id) {
        return Result.success(this.service.getDetail(id));
    }

    @PostMapping({"/save"})
    //@RequiresPermissions({"auth:org:add"})
    public Result<String> save(@RequestBody OrgAddUpdateDTO param) {
        return Result.success(this.service.saveByDTO(param));
    }

}
